//==================================================================
//  Copyright (C) 2006-2007  Davide Pasca
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2.1 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//==================================================================
///
///
///
///
//==================================================================

#ifndef GXY_FONT_H
#define GXY_FONT_H

#include "psys.h"
#include "gxy_base.h"

//==================================================================
namespace GXY {

//==================================================================
enum {
	ALIGN_LEFT		= -1,
	ALIGN_CENTER	=  0,
	ALIGN_RIGHT		=  1,
};

//==================================================================
#define GXY_MAX_FONTS	50

//==================================================================
void LoadFont( int font_idx, const TCHAR *fnamep,
						int cell_w, int cell_h,
						int offx, int offy,
						int is_prop,
						const TCHAR *custom_map, int custom_map_len );

void LoadFont( int font_idx, const TCHAR *fnamep, int cell_w, int cell_h, int is_prop );

void MLoadFontBegin( const TCHAR *fnamep );
void MLoadFontEnd();
void MLoadFontNext(
	int font_idx,
	int cell_w,
	int cell_h,
	int offx,
	int offy,
	int is_prop,
	int			*y_corr_map=NULL,
	const TCHAR	*custom_map=NULL,
	int			custom_map_len=0 );

float GetFontHeight(void);
float GetCharWidth( int ch );
float CalcStringWidth( const TCHAR *strp );

//==================================================================
void SetFont( int font_idx );
void SetFontScale( float sca_x, float sca_y );
void SetFontProportional( int onoff );

void DrawString( float px, float py, const TCHAR *strp );
void DrawStringAlign( float px, float py, int align_x, int align_y, const TCHAR *strp );

void CalcDrawStringSize( const TCHAR *strp, float &out_width, float &out_height );

void DrawStringRectAlign( const Rect &rc,
							int align_x,
							int align_y,
							const TCHAR *strp );

void DrawStringRectAlign( float rcx, float rcy,
							float rcw, float rch,
							int align_x,
							int align_y,
							const TCHAR *strp );

void DrawStringF_vs( float px, float py, const TCHAR *strp, va_list va );
void DrawStringF( float px, float py, const TCHAR *strp, ... );
void DrawStringAlignF( float px, float py, int align_x, int align_y, const TCHAR *strp, ... );

void GetDrawStringPixelSize( float out_size[2] );

//==================================================================
//== Private
//==================================================================
enum {
	FONT_USE_EMPTY = 0,
	FONT_USE_ASCII,
};

//==================================================================
extern u_char	_font_use_table[GXY_MAX_FONTS];

//==================================================================
//== FONT ASCII
//==================================================================
float getCharWidth_a( int ch );
float calcStringWidth_a( const TCHAR *strp );
void drawString_a( const TCHAR *strp, float x, float y, int align_x, int align_y );
float getFontHeight_a(void);

//==================================================================
};

#endif
